package cn.w.outdoor.lib.model;

import cn.w.outdoor.lib.common.CommonMethods;

public class Intercom_Msg {

    public final static int MSG_INTERCOM_NORMAL = 0x1000;
    public final static int MSG_INTERCOM_CALL = 0x1001;
    public final static int MSG_INTERCOM_RINGING = 0x1002;
    public final static int MSG_INTERCOM_ACCEPT = 0x1003;
    public final static int MSG_INTERCOM_HANGUP = 0x1004;
    public final static int MSG_INTERCOM_BUSY = 0x1005;
    public final static int MSG_INTERCOM_TIMEOUT = 0x1006;
    public final static int MSG_INTERCOM_UNLOCK = 0x1007;
    public final static int MSG_INTERCOM_ELEVATOR = 0x1009;

    public static String getCommandDesc(int uCmd) {
        switch (uCmd) {
            case MSG_INTERCOM_NORMAL:
                return "NORMAL";
            case MSG_INTERCOM_CALL:
                return "CALL";
            case MSG_INTERCOM_RINGING:
                return "RINGING";
            case MSG_INTERCOM_ACCEPT:
                return "ACCEPT";
            case MSG_INTERCOM_HANGUP:
                return "HANGUP";
            case MSG_INTERCOM_BUSY:
                return "BUSY";
            case MSG_INTERCOM_TIMEOUT:
                return "TIMEOUT";
            case MSG_INTERCOM_UNLOCK:
                return "UNLOCK";
            case MSG_INTERCOM_ELEVATOR:
                return "ELEVATOR";
        }
        return "未知";
    }

    private byte[] intercom_msg;

    public Intercom_Msg() {
        this(MSG_INTERCOM_NORMAL);
    }

    public Intercom_Msg(int uCmd) {
        intercom_msg = new byte[92];
        setuCmd(uCmd);
    }

    public Intercom_Msg(byte[] bytes) {
        intercom_msg = bytes;
    }

    public int getuCmd() {
        return CommonMethods.bytesToInt(intercom_msg, 0);
    }

    public void setuCmd(int uCmd) {
        CommonMethods.intInsertIntoBytes(intercom_msg, 0, uCmd);
    }

    public byte[] generateToBytes() {
        return intercom_msg;
    }

    @Override
    public String toString() {
        return getCommandDesc(this.getuCmd());
    }
}
